package practise.mulitThreads.Cache;

import java.util.*;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;

/**
 * Created by richard on 4/27/14.
 */
public class CopyOnWriteCache<K> extends ArrayList<K> {
    ReadWriteLock readWriteLock = new ReentrantReadWriteLock();
    private volatile int capability = 10;
    private volatile int size = 0;

    public CopyOnWriteCache(int capability){
        this.capability = capability;
    }

    @Override
    public int size() {

        return super.size();
    }

    @Override
    public boolean contains(Object o) {
        return super.contains(o);
    }

    @Override
    public boolean isEmpty() {
        return super.isEmpty();
    }

    @Override
    public K get(int index) {
        return (K) Arrays.copyOf(this.toArray(), size)[index];
    }

    @Override
    public K set(int index, K element) {
        return super.set(index, element);
    }

    @Override
    public boolean add(K k) {
        return super.add(k);
    }

    @Override
    public K remove(int index) {
        return super.remove(index);
    }

    @Override
    public boolean remove(Object o) {
        return super.remove(o);
    }

    @Override
    public void add(int index, K element) {
        super.add(index, element);
    }
}
